﻿using System;
using System.Linq.Expressions;
using SBACN.WebSite.Code;
using SBACN.WebSite.Models;

namespace SBACN.WebSite
{
    public partial class HeadlineNews : BasePage
    {
        public int PageFlag { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            BindData(1);
        }

        protected void BindData(int pageIndex)
        {
            this.PageFlag = (pageIndex - 1) * this.Pager1.PageSize;
            int records = 0;
            string t = Request.QueryString["st"];
            Expression<Func<TB_News, bool>> f = (p => p.Type == t && p.IsEn == false);
            Expression<Func<TB_News, DateTime>> order = (c => c.CreateDate);
            var resultQ = DAL.DALHelper.Instance.GetList<TB_News, DateTime>(f, order, false, this.Pager1.PageSize, pageIndex, out records);

            this.rptHeadlineNews.DataSource = resultQ;
            this.rptHeadlineNews.DataBind();
            this.Pager1.RecordCount = records;
            this.Pager1.InitControl();
        }
        protected void BindSelectedPageIndexChanged(int pageIndex, int nextPage)
        {
            BindData(nextPage);
        }
    }
}